import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import {View} from '@tarojs/components'

export default class Index extends Component {
  UNSAFE_componentWillMount() {
    const params = Taro.getCurrentInstance().router.params
    if (process.env.TARO_ENV === 'weapp') {
      if (Object.keys(params).length > 0) {
        let text = '?'
        for (const key in params) {
          text += `${key}=${params[key]}&`
        }
        if(process.env.TARO_ENV === 'weapp'){
          Taro.switchTab({url: '/pages/index/index' + text})
        } else {
          window.location.href = '/pages/index/index' + text
        }
      } else {
        if(process.env.TARO_ENV === 'weapp'){
          Taro.switchTab({url: '/pages/index/index'})
        } else {
          window.location.href = '/pages/index/index'
        }
      }
    }
  }

  render() {
    return (
      <View />
    )
  }
}
